package Cursus.Listeners;

import java.awt.*;
import java.awt.event.*;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;

public final class TestJW extends JFrame {
    public TestJW() {
        addWindowListener(new WinClosing());
        setBounds(100, 100, 300, 300);
        splashScreen();
        setVisible(true);
    }

    public void splashScreen() {
        JWindow jw = new JWindow();
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        jw.setSize(screen.width, screen.height);
        URL imageLoc = ClassLoader.getSystemResource("images/foto.jpg");
        JLabel pict = new JLabel(new ImageIcon(imageLoc), JLabel.CENTER);
        JLabel lab = new JLabel("Goeiemiddag!", JLabel.CENTER);
        lab.setFont(new Font("Serif", Font.BOLD, 24));
        lab.setForeground(Color.black);
        jw.getContentPane().add(pict, BorderLayout.CENTER);
        jw.getContentPane().add(lab,BorderLayout.NORTH);
        jw.setVisible(true);
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {}
        jw.setVisible(false);
    }

    public static void main(String args[]) {
        TestJW tjw = new TestJW();
    }

    public class WinClosing extends WindowAdapter {
        @Override
        public void windowClosing(WindowEvent we) {
            System.exit(0);
        }
    }
}
